import java.io.InputStream;
import java.util.Scanner;


public class Recebedor implements Runnable {
	
	private InputStream servidor;
	
	private MainFrame mainFrame;
	
	public Recebedor( final InputStream servidor, final MainFrame mainFrame ) {
		
		this.servidor = servidor;
		this.mainFrame = mainFrame;
	}
	
	public void run() {
		
		//Recebe mensagens do servidor e imprime na tela
		Scanner s = new Scanner( this.servidor );
		
		while ( s.hasNextLine() ) {
			
			String mensagem = s.nextLine();
			
			mainFrame.getPainelChat().getChatText().append( mensagem + "\n" );
		}
	}

	public MainFrame getMainFrame() {
		return mainFrame;
	}

	public void setMainFrame(MainFrame mainFrame) {
		this.mainFrame = mainFrame;
	}
}
